package com.bx.implatform.ucc.config;

import com.bx.implatform.ucc.interceptor.UccHeaderInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.client.RestTemplate;

import java.util.Arrays;
import java.util.List;

@Configuration
public class UccRestTemplateConfig {

    @Bean("uccRestTemplate")
    public RestTemplate uccRestTemplate(
            RedisTemplate<String, Object> redisTemplate // 注入 RedisTemplate
    ) {
        RestTemplate restTemplate = new RestTemplate();
        // 定义不拦截的路径（可配置化）
        List<String> excludePaths = List.of(
                "/system-service/api-v1.0/SysUser/login",
                "/control/validateCode/get.json",
                "/control/validateCode/validate.json"
        );
        restTemplate.getInterceptors().add(new UccHeaderInterceptor(redisTemplate,excludePaths));
        return restTemplate;
    }
}
